using System;
using bitzhuwei.Compiler;

namespace bitzhuwei.GLSLFormat {
    /// <summary>
    /// Correspond to the Vn node struct_declaration_list in the grammar(GLSL).
    /// </summary>
    internal partial class Vnstruct_declaration_list : IFullFormat {
        // [294] struct_declaration_list = struct_declaration ;
        // [295] struct_declaration_list = struct_declaration_list struct_declaration ;



        private readonly TokenRange _scope;
        public TokenRange Scope => _scope;
        public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
            var config = new BlankConfig();
            context.PrintBlanksAnd(this.r0, preConfig, writer);
            var postfixCount = this.postfix.Count;
            for (var i = 0; i < postfixCount; i++) {
                if (i == 0) {
                    context.PrintCommentsBetween(this.postfix[i], this.r0, config, writer);
                }
                else {
                    context.PrintCommentsBetween(this.postfix[i], this.postfix[i - 1], config, writer);
                }
                context.PrintBlanksAnd(this.postfix[i], config, writer);
            }
        }

        private readonly List<Vnstruct_declaration> postfix = new();
        public void Add(Vnstruct_declaration r0) {
            this.postfix.Add(r0);
            this._scope.end = r0.Scope.end;
        }

        public readonly Vnstruct_declaration r0;
        public Vnstruct_declaration_list(Vnstruct_declaration r0) {
            this.r0 = r0;
            this._scope = new TokenRange(r0);
        }


    }
}
